
var njcode;// 年级编号
var bjcode;// 班级编号
var Objcode;//对象
var interv1;
var interv2;
function initLoading() {
	DWREngine.setPreHook(function () {
		loading();
	});
	DWREngine.setPostHook(function () {
		remove_loadingdiv();
	});
}
function loading() {
	show_loadingpage();
}
var div_left = 0;
var div_right = 0;
var loading_constant = 0;
function move_loading() {
	var move_div = document.getElementById("move_div");
	var move_div_arry = new Array();
	move_div_arry[1] = document.getElementById("move_div1");
	move_div_arry[2] = document.getElementById("move_div2");
	move_div_arry[3] = document.getElementById("move_div3");
	move_div_arry[4] = document.getElementById("move_div4");
	move_div_arry[5] = document.getElementById("move_div5");
	if (div_left < 250) {
		move_div.style.left = div_left + "px";
		div_left += 5;
		div_right = 250;
	} else {
		if (div_right > -77) {
			for (i = 1; i < 6; i++) {
				move_div_arry[i].className = "move_div" + (6 - i);
			}
			move_div.style.left = div_right + "px";
			div_right -= 4;
		} else {
			div_left = -77;
			for (i = 1; i < 6; i++) {
				move_div_arry[i].className = "move_div" + i;
			}
		}
	}
}
function flicker_text() {
	var loading_text = document.getElementById("loading_text");
	if (loading_constant == 0) {
		loading_text.style.color = "#4e7f31";
		loading_constant = 1;
	} else {
		loading_text.style.color = "#000000";
		loading_constant = 0;
	}
}
function show_loadingpage() {
	var cover_div = document.createElement("div");
	cover_div.id = "cover_divone";
	cover_div.style.height = "100%";
	cover_div.style.width = "100%";
	cover_div.style.position = "absolute";
	cover_div.style.left = "0";
	cover_div.style.top = "0";
	cover_div.style.zIndex = "3000";
	cover_div.innerHTML = "<iframe scrolling=\"no\" frameborder=\"0\" width=\"100%\" height=\"100%\" style=\"z-index:3000;\"></iframe>";
	cover_div.style.filter = "alpha(opacity=1)";
	cover_div.style.opacity = "0.1";
	var cover_div2 = document.createElement("div");
	cover_div2.id = "cover_divtwo";
	cover_div2.style.height = "100%";
	cover_div2.style.width = "100%";
	cover_div2.style.position = "absolute";
	cover_div2.style.left = "0";
	cover_div2.style.top = "0";
	cover_div2.style.zIndex = "3010";
	cover_div2.style.background = "#ffffff";
	cover_div2.style.filter = "alpha(opacity=3)";
	cover_div2.style.opacity = "0.3";
	var load_div = document.createElement("div");
	load_div.id = "load_div";
	load_div.style.height = "100%";
	load_div.style.width = "100%";
	load_div.style.position = "absolute";
	load_div.style.left = "0";
	load_div.style.top = "0";
	load_div.style.zIndex = "3100";	
	//load_div.style.textAlign='center';
	load_div.style.paddingTop = document.body.offsetHeight / 2 - 50 + "px";
	load_div.style.paddingLeft = document.body.offsetWidth / 2 - 100 + "px";
	document.body.appendChild(cover_div);
	document.body.appendChild(cover_div2);
	document.body.appendChild(load_div);
	load_div.innerHTML = "<div class=\"border_div\" id=\"border_div\"><div id=\"move_div\"><div class=\"move_div5\" id=\"move_div5\"></div><div class=\"move_div4\" id=\"move_div4\"></div><div class=\"move_div3\" id=\"move_div3\"></div><div class=\"move_div2\" id=\"move_div2\"></div><div class=\"move_div1\" id=\"move_div1\"></div></div></div><p id=\"loading_text\" style=\"margin:0 0 0 80px \">\u6b63\u5728\u52a0\u8f7d\u6570\u636e\uff0c\u8bf7\u7a0d\u5019......</p>";
	interv1=setInterval('move_loading()', 50);
	interv2=setInterval(flicker_text, 500);
}
function remove_loadingdiv() {
	if (window.interv1) {
		clearInterval(window.interv1);
	}
	if (window.interv2) {
		clearInterval(window.interv2);
	}
	var cover_divone = document.getElementById("cover_divone");
	var cover_divtwo = document.getElementById("cover_divtwo");
	var load_div = document.getElementById("load_div");
	document.body.removeChild(cover_divone);
	document.body.removeChild(cover_divtwo);
	document.body.removeChild(load_div);
}
function init() {
	initLoading();
	DWREngine.setTimeout(5000);
}
function getGrade(njid, bjid, obj) {
	studwr.getGrade(graderow);
	njcode = njid;
	bjcode = bjid;
	Objcode = obj;
}
function graderow(data) {
	DWRUtil.removeAllOptions("nj");
	DWRUtil.addOptions("nj", {"":"\u8bf7\u9009\u62e9\u5e74\u7ea7"});
	DWRUtil.addOptions("nj", data);
	selectGrad(njcode);
	if (Objcode == "teacher") {
		getTeacherClass();
	} else {
		getClass();
	}
}

//教师年级
function getTNj(njid, bjid) {
	studwr.getTeacherNj(TNJRow);
	if (null != njid || "" != njid) {
		njcode = njid;
	}
	if (null != bjid || "" != bjid) {
		bjcode = bjid;
	}
}
function TNJRow(data) {
	DWRUtil.removeAllOptions("nj");
	DWRUtil.addOptions("nj", {"":"\u8bf7\u9009\u62e9\u5e74\u7ea7"});
	if (null != data || "" != data) {
		DWRUtil.addOptions("nj", data);
		if (null != njcode || "" != njcode) {
			for (var property in data) {
				njcode = property;
				break;
			}
		}
		selectGrad(njcode);
		getTeacherClass();
	}
}
//获得年级下的班级
function getClass() {
	var njid = document.getElementById("nj").value;
	njcode = njid;
	studwr.getClass(njcode, classrow);
}
//获得老师所教班级
function getTeacherClass() {
	init();
	var njid = document.getElementById("nj").value;
	njcode = njid;
	studwr.getTeacherClass(njcode, classrow);
}
function classrow(data) {
	DWRUtil.removeAllOptions("bj");
	DWRUtil.addOptions("bj", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	if (null != data || "" != data) {
		DWRUtil.addOptions("bj", data);
		if (null == bjcode || "" == bjcode) {
			for (var property in data) {
				bjcode = property;
				break;
			}
		}
		selectClass(njcode, bjcode);
	}
}
function selectGrad(njcode) {
	if (njcode != "" && njcode != null) {
		DWRUtil.setValue("nj", njcode);
	}
}
function selectClass(njcode, bjcode) {
	if (bjcode != "" && bjcode != null) {
		DWRUtil.setValue("bj", bjcode);
	}
	if (njcode != "" && njcode != null) {
		DWRUtil.setValue("nj", njcode);
	}
}

//获得省份下拉框
function ProvinceMap() {
	studwr.ProvinceMap(getProvinceSelect);
}
function getProvinceSelect(data) {
	DWRUtil.removeAllOptions("province");
	DWRUtil.addOptions("province", {"":"\u8bf7\u9009\u62e9\u7701\u4efd"});
	if (null != data) {
		DWRUtil.addOptions("province", data);
	}
}
//获得市区下拉框
function CityMap() {
	var pid = $("province").value;
	studwr.CityMap(pid, getCitySelect);
}
function getCitySelect(data) {
	DWRUtil.removeAllOptions("city");
	DWRUtil.addOptions("city", {"":"\u8bf7\u9009\u62e9\u5e02\u533a"});
	DWRUtil.addOptions("city", data);
}
function fkProvinceMap() {
	studwr.ProvinceMap(getfkProvinceSelect);
}
function getfkProvinceSelect(data) {
	DWRUtil.removeAllOptions("fkprovince");
	DWRUtil.addOptions("fkprovince", {"":"\u8bf7\u9009\u62e9\u7701\u4efd"});
	if (null != data) {
		DWRUtil.addOptions("fkprovince", data);
	}
}
//获得市区下拉框
function fkCityMap() {
	var pid = $("fkprovince").value;
	studwr.CityMap(pid, getFKCitySelect);
}
function getFKCitySelect(data) {
	DWRUtil.removeAllOptions("fkcity");
	DWRUtil.addOptions("fkcity", {"":"\u8bf7\u9009\u62e9\u5e02\u533a"});
	DWRUtil.addOptions("fkcity", data);
}
function getAdminStuNj(njid, bjid) {
	njcode = njid;
	bjcode = bjid;
	studwr.getGrade(AdminNjSelectOption);
}
function getTearcherStuNj(njid, bjid) {
	njcode = njid;
	bjcode = bjid;
	studwr.getGrade(TearcherNjSelectOption);
}
function AdminNjSelectOption(data) {
	DWRUtil.removeAllOptions("njcode");
	DWRUtil.addOptions("njcode", {"":"\u8bf7\u9009\u62e9\u5e74\u7ea7"});
	DWRUtil.addOptions("njcode", data);
	selectStuGrad(njcode);
	getStuGLBj();
}
function TearcherNjSelectOption(data) {
	DWRUtil.removeAllOptions("njcode");
	DWRUtil.addOptions("njcode", {"":"\u8bf7\u9009\u62e9\u5e74\u7ea7"});
	DWRUtil.addOptions("njcode", data);
	selectStuGrad(njcode);
	getStuCXBj();
}
function selectStuGrad(nj) {
	if (nj != "" && nj != null) {
		DWRUtil.setValue("njcode", nj);
	}
}
function getStuCXBj() {
	var nj = document.getElementById("njcode").value;
	if ("" != nj) {
		studwr.getTeacherClass(nj, BjSelectOption);
	} else {
		BjSelectOption("");
	}
}
function getStuGLBj() {
	var nj = document.getElementById("njcode").value;
	if ("" != nj) {
		studwr.getClass(nj, BjSelectOption);
	} else {
		BjSelectOption("");
	}
}
function BjSelectOption(data) {
	if (null != data && "" != data) {
		DWRUtil.removeAllOptions("bjcode");
		DWRUtil.addOptions("bjcode", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
		DWRUtil.addOptions("bjcode", data);
		selectStuBj(bjcode);
	} else {
		DWRUtil.removeAllOptions("bjcode");
		DWRUtil.addOptions("bjcode", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	}
}
function selectStuBj(bj) {
	if (bj != "" && bj != null) {
		DWRUtil.setValue("bjcode", bj);
	}
}
function upStuNj(njid, bjid) {
	studwr.getGrade(upGradeRow);
	njcode = njid;
	bjcode = bjid;
}
function upGradeRow(data) {
	DWRUtil.removeAllOptions("nj");
	DWRUtil.addOptions("nj", {"":"\u8bf7\u9009\u62e9\u5e74\u7ea7"});
	if (null != data) {
		DWRUtil.addOptions("nj", data);
	}
	selectGrad(njcode);
	upStuBj();
}
function upStuBj() {
	var njid = document.getElementById("nj").value;
	njcode = njid;
	studwr.getClass(njcode, upClassRow);
}
function upClassRow(data) {
	DWRUtil.removeAllOptions("bj");
	DWRUtil.addOptions("bj", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	if (null != data || "" != data) {
		DWRUtil.addOptions("bj", data);
		if (null != bjcode || "" != bjcode) {
			for (var property in data) {
				bjcode = property;
				break;
			}
		}
		upSelectClass(njcode, bjcode);
	}
}
function upSelectClass(nj, bj) {
	if (bj != "" && bj != null) {
		DWRUtil.setValue("bj", bj);
	}
	if (nj != "" && nj != null) {
		DWRUtil.setValue("nj", nj);
	}
}

